package com.ht.springcloud.item.controller;

import com.ht.springcloud.item.pojo.Item;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/items")
public class ItemController {
    private int count;
    @GetMapping("/item/{id}")
    public Item getItemById(@PathVariable Integer id, HttpServletRequest request) {
        System.err.println(request.getRemoteAddr());
        count++;
        System.err.println(count);
        Item item = new Item();
        item.setId(id);
        item.setCategory("电脑");
        item.setName("笔记本电脑");
        item.setPrice(1000000);
        return item;
    }
}
